Python has the sqlite database engine built in so it seems to be an obvious choice provided it can meet our needs (probably, with a max DB size of 140 TB and an unreachable row limit). For the first bit we'll import the module sqlite3, create our db, and set up the schema. Setting up the db is a one time thing. The next steps will be simulating the CCP while saving to a db, then querying the db to create an ICCP lookup table.


In [1]:
import sqlite3
conn = sqlite3.connect('ICCP-database.sqlite')
c = conn.cursor()

In [2]:
c.execute('create table if not exists sim(sim_num integer primary key, n integer, param real, max_draw integer);')
c.execute('create table if not exists draws(sim_num integer, draw_num integer, uniques integer, foreign key(sim_num) references sim(sim_num), primary key(sim_num, draw_num));')


Out[2]:
<sqlite3.Cursor at 0x436c6c0>

In [4]:
conn.commit()
conn.close()

This makes a database with two tables, one is a table for storing the parameters for each sim run, the second table is for recording each individual draw. The draw records are linked to the sim parameters through the use of the foriegn key "sim_num."